import pandas as pd
from selenium import webdriver
from openpyxl.workbook import Workbook

url = 'https://www.runoob.com/html/html-tutorial.html'
x = "//div[@id='leftcolumn']/a"
driver = webdriver.Chrome()
driver.get(url=url)
s = driver.find_elements_by_xpath(x)

datas = []

for i in s:
   url_text = i.text.strip()
   url_html = i.get_attribute('href')
   datas.append(
      dict(
         url_text = url_text,
         url_html = url_html,
      )
   )
cainiao_html = pd.DataFrame(datas)
writer = pd.ExcelWriter('cainiao.xlsx')
cainiao_html.to_excel(writer, sheet_name='sheet1')
writer.save()




























